package com.mi.soul.whale.module.system.controller;

import com.mi.rule.auth.Public;
import com.mi.rule.resource.ResC;
import com.mi.rule.resource.ResM;
import com.mi.rule.util.project.SRS;
import com.mi.soul.whale.module.system.service.SystemService;
import com.mi.soul.whale.mybatis.entity.SysMenu;
import com.mi.soul.whale.mybatis.entity.SysResource;
import com.mi.soul.whale.mybatis.entity.SysRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@ResC("系统管理")
@RestController
@RequestMapping("/system")
public class SystemController {
    @Autowired
    SystemService systemService;

    @Public
    @ResM("读取资源树")
    @RequestMapping("/resource/tree")
    public SRS resourceTree(@RequestBody SRS param) {
        List<SysRole> roles = systemService.roles();
        List<SysMenu> menus = systemService.menus();
        List<SysResource> resources = systemService.resources();
        List<String> strings = systemService.roleMenuUrls(1);
        List<SysMenu> sysMenus = systemService.roleMenuList(1);
        List<String> strings1 = systemService.roleResourceUrls("1");
        List<SysResource> sysResources = systemService.roleResourceList("1");

        return SRS.bySuccess();
    }

    @Public
    @ResM("刷新角色资源缓存")
    @RequestMapping("/refresh/roleResource")
    public SRS refreshRoleResource(@RequestBody SRS param) {
        return systemService.systemResourceCleanAdd(param);
    }

    @Public
    @ResM("刷新角色菜单缓存")
    @RequestMapping("/resource/roleMenu")
    public SRS resourceRoleMenu(@RequestBody SRS param) {
        return systemService.systemResourceCleanAdd(param);
    }

}
